package com.wangjin.javaProject;

import com.alibaba.fastjson.JSONObject;
import com.wangjin.javaProject.address.Address;
import com.wangjin.javaProject.bean.HotVideo;
import com.wangjin.javaProject.bean.HotVideoCommon;
import com.wangjin.javaProject.request.HttpUtils;
import com.wangjin.javaProject.service.GetBestBlockHash;
import com.wangjin.javaProject.service.HotVideoService;

import java.io.IOException;
import java.security.KeyPair;
import java.util.List;
import java.util.Scanner;

/**
 * Creator: WangJin
 * @desc:该类是项目的主函数，程序的入口
 * Creation Data: 2021/12/12 11:57
 **/
public class Main {
    public static void main(String[] args) {
        run();
    }

    public static void run() {
        System.out.println("========比特币系统设计期末考查系统========");
        System.out.println("本系统已实现一下功能:");
        System.out.println("1.热门视频抓取  2.和比特币客户端通信  3.比特币地址推导  0.退出");
        while (true) {
            userMenu();
        }
    }
    public static void userMenu(){
        System.out.println("请输入要使用的功能序号:");
        System.out.println("1.热门视频抓取  2.和比特币客户端通信  3.比特币地址推导");
        Scanner scanner = new Scanner(System.in);
        int num = scanner.nextInt();
        switch (num){
            case 1://热门视频抓取
                HotVideoService hotVideo = new HotVideoService();
                List<HotVideo>videoList = hotVideo.getHotVideo();
//                for (HotVideo video : videoList){
//                    System.out.println(video.getShare_url());
//                }
                for (HotVideo video : videoList) {
                    System.out.println(video.getShare_url());
                }

                break;
            case 2:
                GetBestBlockHash getBestBlockHash = new GetBestBlockHash();
                String getbestblockhash = getBestBlockHash.getbestblockhash();
                System.out.println(getbestblockhash);
                break;
            case 3:
                Address address = new Address();
                KeyPair keyPair = address.generateKeys();
                String s = address.newAddress(keyPair);
                System.out.println(s);
                break;
            case 0:
                System.out.println("谢谢使用，下次再见");
                System.exit(0);
            default:
                System.out.println("输入有误，重新输入:");
                break;
        }
    }
}
